package ${package}.${moduleName}.service.impl;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import java.util.List;
import com.qdone.framework.core.dao.BaseDao;
import com.qdone.framework.core.page.PageList;
import ${package}.${moduleName}.model.${className};
import ${package}.${moduleName}.service.${className}Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Isolation;

/**
* ${classname}服务接口
* ${comments}
* @author ${author}
* @email ${email}
* @date ${datetime}
*/
@Service("${classname}Service")
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
public class ${className}ServiceImpl implements ${className}Service{

	@Resource(name = "baseDao")
	private BaseDao baseDao;

	/**
	* 分页查询
	* @param entity 查询参数
	* @return 分页查询结果
	*/
	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public PageList<${className}> selectPage(${className} entity) {
	     return baseDao.selectPage("${package}.${moduleName}.mapper.${className}.select", entity);
	}

	/**
	* 查看
	* @param pk 主键
	* @return 根据主键查询结果
	*/
	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public ${className} view(${pk.attrType} pk) {
	     return (${className})baseDao.view("${package}.${moduleName}.mapper.${className}.view", pk);
	}


	/**
	* 新增(主键可以使用数据库自增，也可以使用mybatis生成)
	* @param entity 新增参数
	* @return 新增结果,结果中含有主键，操作结果
	*/
	@Override
	@Transactional(readOnly = false,rollbackFor = Exception.class)
	public ${className} insert(${className} entity) {
	    entity.setOperateResult(baseDao.insert("${package}.${moduleName}.mapper.${className}.insert", entity));
	    return entity;
	}

	/**
	* 更新
	* @param entity 更新参数
	* @return 更新结果,结果中含有操作结果
	*/
	@Override
	@Transactional(readOnly = false,rollbackFor = Exception.class)
	public ${className} update(${className} entity){
	    entity.setOperateResult(baseDao.update("${package}.${moduleName}.mapper.${className}.update", entity));
	    return entity;
	}

	/**
	* 批量删除
	* @param pkList 对象集合
	* @return 批量删除集合参数
	*/
	@Override
	@Transactional(readOnly = false,rollbackFor = Exception.class)
	public int batchDelete(List<${className}> pkList) {
	    return baseDao.batchDelete("${package}.${moduleName}.mapper.${className}.batchDelete", pkList);
    }


}
